#pragma once
#include "string"

#include "ObjectDetector.h"
#include "ImageReader.h"

using namespace std;

class FingerRootsDetector : virtual public ObjectDetector
{
private:
  ImageReader ir;
  cv::Mat detected_result;
  cv::Mat gray_tmp;
  //finger roots [x1,y1,x2,y2,x3,y3]
  int fingerConner[6];
  bool isLeftHand = false;

  vector<cv::Point> getCornerPoints();
  bool detectLR();
  void findFingerRoots(vector<cv::Point> candidator);
  float distance(cv::Point a, cv::Point b);
  vector<cv::Point> filterFingerRoots_aggregate(vector<cv::Point> candidator);
  vector<cv::Point> filterFingerRoots_distance(vector<cv::Point> candidator);

public:
  FingerRootsDetector(ImageReader gray);
  ~FingerRootsDetector();
  FingerRootsDetector detect();
  cv::Mat getResult() { return detected_result; };
  const int getDetectedArr(int *&result);
};